
<template>
   <div>
       <!-- 头部 -->
    <a-layout-header>
        <a-button type="primary" v-if="!username">
             <a href="/login">登录</a> 
        </a-button>

        <p v-if="username">
            <font color='white'>欢迎你</font>
            <a-button type='primary' >
                {{username}}
            </a-button>

            <a-button type='denger' @click="exit()">退出
            </a-button>
        </p>
    </a-layout-header>
   </div>
    
</template>

<script>
export default {
    data(){
        return{
        username:localStorage.getItem('username'),
        }
    },
    methods:{
    //退出登录
    exit(){
          localStorage.removeItem('username')
          localStorage.removeItem('token')
          this.$router.go(0) 
      },
    }
}
</script>

<style>

</style>